// Created from GroupGenerationTemplate
// For Decisions HL7 Engine
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using DecisionsFramework.Design.Properties;
using Decisions.HL7.DataTypes;
using ST = System.String;
using SI = System.String;
using IS = System.String;
using ID = System.String;
using SNM = System.String;

namespace Decisions.HL7.Message
{
    [DataContract]
	public class PRODUCT_SERVICE_SECTION_EHC_E10 : AbstractGroup
    {
        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("14 PSS",14)]
  	    [HL7Field(HL7Version.v26, 14, HL7Repeat.False, HL7Required.True,"PSS")]
	    public PSS PSS {get;set;}

        /// -----------------------------
        /// -----------------------------
		[DataMember]
	    [PropertyClassification("15 PRODUCT_SERVICE_GROUP",15)]
  	    [HL7Field(HL7Version.v26, 15, HL7Repeat.True, HL7Required.True,"PRODUCT_SERVICE_GROUP_EHC_E10")]
	    public PRODUCT_SERVICE_GROUP_EHC_E10[] PRODUCT_SERVICE_GROUP {get;set;}



		#region Parser Helpers and Conrete Impls

        internal override void ConsumeTextSegmentsForGroup(Stack<string> availableData, HL7ParserOptions options) {

			PSS = PopSegmentParseAndCheckRequired<PSS>(availableData, options, "PSS");
			PRODUCT_SERVICE_GROUP = ProcessGroupArray<PRODUCT_SERVICE_GROUP_EHC_E10>(availableData, options, "PRODUCT_SERVICE_GROUP");
        }

		internal override bool CanConsume(string availableData, HL7ParserOptions options)
        {
			bool isPSS = availableData.StartsWith("PSS", StringComparison.OrdinalIgnoreCase);
			if (IsRequired("PSS", options.Version) || isPSS) {
				return isPSS;
			}
			PRODUCT_SERVICE_GROUP_EHC_E10 testPRODUCT_SERVICE_GROUP_EHC_E10 = new PRODUCT_SERVICE_GROUP_EHC_E10();
			bool grpCCPRODUCT_SERVICE_GROUP_EHC_E10 = (testPRODUCT_SERVICE_GROUP_EHC_E10.CanConsume(availableData, options));
			if (IsRequired("PRODUCT_SERVICE_GROUP", options.Version) || grpCCPRODUCT_SERVICE_GROUP_EHC_E10) {
				return grpCCPRODUCT_SERVICE_GROUP_EHC_E10;
			}
			return false;
        }

        private static Dictionary<string, bool> SEGMENT_VERSION_REQUIRED_MAP = new Dictionary<string, bool>();

		protected override Dictionary<string, bool> MAP_OF_SEGMENT_TO_REQUIRED
        {
            get
			{
				return SEGMENT_VERSION_REQUIRED_MAP;
			}
        }

		public override string HL7ENTITY_TYPE_NAME
        {
            get {
				return "PRODUCT_SERVICE_SECTION";
			}
        }

        static PRODUCT_SERVICE_SECTION_EHC_E10() {

             SetupStaticPropertyMap(SEGMENT_VERSION_REQUIRED_MAP, typeof(PRODUCT_SERVICE_SECTION_EHC_E10));

        }

		#endregion

		public override string GetER7(HL7ParserOptions options)
		{
			List<string> segmentData = new List<string>();
		 if (PSS != null) {
			string segmentValue = PSS.GetER7(options);
			if (string.IsNullOrEmpty(segmentValue) == false) {
				segmentData.Add(segmentValue);
			}
		 }
		 if (PRODUCT_SERVICE_GROUP != null && PRODUCT_SERVICE_GROUP.Length > 0) {
			for (int i = 0; i < PRODUCT_SERVICE_GROUP.Length; i++) {
				string segmentValue = PRODUCT_SERVICE_GROUP[i].GetER7(options);
				if (string.IsNullOrEmpty(segmentValue) == false) {
					segmentData.Add(segmentValue);
				}
			}
		 }
           return string.Join(HL7ParserConstants.SEGMENT_SEPARATOR, segmentData.ToArray());
        
        }
    }
}

